#!/usr/bin/perl

use strict;

use ApacheConfigFile;

sub mainSecApache{
	my $conf_file = $_[0];
	my @apache_directives=();
	my $apacheobject=new ApacheConfigFile($conf_file);
	$apacheobject->readConfigFile;
	$apacheobject->readBasicConfiguration;

	print "\n#### DIRECTORIOS CONFIGURADOS ####\n";
	foreach ($apacheobject->getDirectories){
		print $_ ."\n";
	}
	
#	print "\n#### MODULOS CONFIGURADOS ####\n";
#	foreach ($apacheobject->getModules){
#		print $_ ."\n";
#	}
	
	print "\n#### INCLUDES CONFIGURADOS ####\n";
	foreach ($apacheobject->getIncludes){
		print $_ ."\n";
	}
	
	print "\n#### ALIAS CONFIGURADOS ####\n";
	foreach ($apacheobject->getAliases){
		print $_ ."\n";
	}
	
	print "\n#### ALIAS DIRS  CONFIGURADOS ####\n";
	foreach ($apacheobject->getAliasesDirs){
		print $_ ."\n";
	}
	
	print "\n#### SCRIPTALIAS CONFIGURADOS ####\n";
	foreach ($apacheobject->getScriptAliases){
		print $_ ."\n";
	}
	
	print "\n#### SCRIPT ALIAS DIRS  CONFIGURADOS ####\n";
	foreach ($apacheobject->getScriptAliasesDirs){
		print $_ ."\n";
	}
	
	print "\n#### ERROR DOCUMENT CONFIGURADOS ####\n";
	foreach ($apacheobject->getErrorDocument){
		chomp $_;
		print $_. " ".$apacheobject->getErrorDocumentValue($_) ."\n";
	}


	print "\n#### INICIO DE SEGUNDO PARSEO ####\n";
	$apacheobject->readIncludes;	
	print $apacheobject->get
}

sub mainSecPHP {

}

sub usage {
	print "Uso: \n";
	print "./sec-apache-php.pl <apache configuration file> <php configuration file> \n";
	return;
}

if($#ARGV+1 != 2){
	usage();
	exit;
}

my $apache_conf_file = $ARGV[0];
my $php_conf_file = $ARGV[1];

my (@apache_conf_content,$php_conf_content);

if (! -e $apache_conf_file){
	print "$apache_conf_file doesnt exist";
	exit;
}

if(! -e $php_conf_file){
	print "$php_conf_file doesnt exist";
	exit;
}

mainSecApache $apache_conf_file;
mainSecPHP $php_conf_file;
